//
//  InStationContactViewController.m
//  Utils
//
//  Created by enghou on 2018/6/12.
//  Copyright © 2018年 xyxorigation. All rights reserved.
//

#import "InStationContactViewController.h"
#import "NetWorkerManager.h"
#import "InStationContactItemModel.h"
@interface InStationContactViewController ()

@end

@implementation InStationContactViewController


-(instancetype)init{
    UIStoryboard *story = [UIStoryboard storyboardWithName:@"ReceiverChoose" bundle:[NSBundle mainBundle]];
    return [story instantiateViewControllerWithIdentifier:@"InStationContactViewController"];
}

-(NSArray *)selectedContacts{
    NSArray *indexpaths = [self.tableView indexPathsForSelectedRows];
    NSMutableArray *targets = [NSMutableArray array];
    for (NSIndexPath *index in indexpaths) {
        InStationContactItemModel *model  = self.source[index.row];
        [targets addObject:model];
    }
    return targets;
}


- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}
- (IBAction)confirmAction:(id)sender {
}

-(void)beginRefresh{
    NSDictionary *param = @{@"word_search":self.searchBar.text};
    [[NetWorkerManager sharedInstance]postWithPath:@"/mobile/comprehensiveGovernance/outbox/getInsideContact.action" parameter:param completeBlock:^(NSDictionary *source) {
        BaseModel *model = [[BaseModel alloc]initWithSourceDict:source listItemClass:NSClassFromString(@"InStationContactItemModel")];
        if (model.success) {
            self.source = [model.list mutableCopy];
            [self.tableView reloadData];
        }else{
            [self alertSome:model.msg];
        }
    } failBlock:^(NSInteger code) {
        [self alertSome:kNetWorkFail];
    }];
}

-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    UIView *header = [[UIView alloc]init];
    header.backgroundColor = [UIColor defaultBackgroundColor];
    UILabel *nameLbl = [[UILabel alloc]init];
    nameLbl.text = @"姓名";
    nameLbl.textAlignment = NSTextAlignmentCenter;
    nameLbl.frame = CGRectMake(0, 0, self.view.width / 2, 44);
    [header addSubview:nameLbl];
    
    UILabel *teamLbl = [[UILabel alloc]init];
    teamLbl.text = @"手机号码";
    teamLbl.textAlignment = NSTextAlignmentCenter;
    teamLbl.frame = CGRectMake(self.view.width / 2, 0, self.view.width / 2, 44);
    [header addSubview:teamLbl];
    return header;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
